# $Id: PKGBUILD 183744 2013-04-27 16:59:09Z pierre $

pkgname=fetchmail
pkgver=6.3.26
pkgrel=1
pkgdesc="A remote-mail retrieval utility"
arch=('i686' 'x86_64')
url="http://fetchmail.berlios.de/"
license=('GPL')
depends=('openssl')
makedepends=('python2')
optdepends=('tk: for using fetchmailconf'
            'python2: for using fetchmailconf')
options=('!makeflags')
install='fetchmail.install'
source=("http://download.berlios.de/$pkgname/${pkgname}-${pkgver}.tar.xz"
        "http://download.berlios.de/$pkgname/${pkgname}-${pkgver}.tar.xz.asc"
        'fetchmail.tmpfiles' 'fetchmail.service')
sha1sums=('de8dbe62a8edfa232ee4278257a1fe67aa1c797a'
          'SKIP'
          '199ba749c829f22286c34aabcf8b7dd5bbd7c0e6'
          '69caf3fd4d4446db3bf53144e4fa8edbdbbfcd10')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  sed -i 's|/usr/bin/env python|/usr/bin/env python2|' fetchmailconf.py
  PYTHON=python2 ./configure --prefix=/usr --with-ssl=/usr
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -d -o 90 -g nobody "${pkgdir}/var/lib/fetchmail"
  install -D -m644 ${srcdir}/fetchmail.tmpfiles ${pkgdir}/usr/lib/tmpfiles.d/fetchmail.conf
  install -D -m644 ${srcdir}/fetchmail.service ${pkgdir}/usr/lib/systemd/system/fetchmail.service
}
